<template>
	<div class="main">
			<div v-for="(item,index) in listData" :key="index" class="activity" @click="openView(item)" >
				<img :src='item.cover[1]' alt="" width="100%" height="100%" />
				<p class="activity-title">{{item.activityName}}</p>
				<p class="time">
					<span>
						{{item.createTime}}
					</span>
				</p>
			</div>
	</div>
</template>

<script>
import api from "../../../api/api.js";
export default {
  data() {
    return {
      listData: [],
      pageIndex: 1
    };
  },
  created() {
    this.getdata();
  },
  methods: {
    getdata() {
      var that = this;
      var str = localStorage.getItem("userid"); //取
      let userid = JSON.parse(str);
      console.log(localStorage.getItem("logindata").accId)
      let datevalue = that.formatDate(new Date().getTime()); //时间年月日时分秒
      let prePushTime = datevalue.substring(0, 11); //取年月日
      console.log(userid);
      that.$http({
          method: "post",
          url: api.baseURL + "getSpecialActivitiesList",
          params: {
            inParam: {
              sysCode: "FH_PUBOPE",
              userId: userid,
              accId: 1,
              currentPage: that.pageIndex,
              pageSize: 10
            }
          }
        })
        .then(function(response) {
          var imgReg =/<img.*?(?:>|\/>)/gi;
          var srcReg = /src=[\'\"]?([^\'\"]*)[\'\"]?/i;
          console.log(response.data.data);
          that.listData = response.data.data;
          for(let item in that.listData){
            that.listData[item].cover = that.listData[item].text.match(imgReg) //<img[^<>]*src=[\'\"]([0-9A-Za-z.\\/]*)[\'\"].(.*?)>")
            that.listData[item].cover = that.listData[item].cover[0].match(srcReg) //<img[^<>]*src=[\'\"]([0-9A-Za-z.\\/]*)[\'\"].(.*?)>")
          }
          console.log(that.listData);
        })
        .catch(function(error) {
          console.log(error);
        });
	},
	openView(item){
		this.$router.push({
      name:"activityconten",
      params:item
    })
	  }
  }
};
</script>

<style scoped>
.main {
  /*margin-top: 20px;*/
  margin-top: 50px;
  margin-bottom: 40px;
  background: #ffffff;
  padding-top: 20px;
  padding: 20px 15px 15px 15px;
}

.activity>img {
  height: 140px;
}

.activity .activity-title {
  font-size: 15px;
  font: 15px/20px "microsoft yahei";
  color: #252525;
}

.activity img {
  border-radius: 8px;
}

.time {
  display: flex;
  justify-content: flex-end;
}

.time span {
  margin-top: 10px;
  margin-bottom: 14px;
  font-size: 13px;
  color: #a1a1a1;
}
</style>